# from selenium import webdriver
# from selenium.webdriver.common.by import By
# import time
# driver = webdriver.Edge()
# driver.get("https://www.toutiao.com/")
# driver.maximize_window()
# time.sleep(6)
# # 找到某个目标元素
# element = driver.find_element(By.XPATH,'//*[@id="root"]/div/div[5]/div[2]/div[6]/a[15]')
# # 滚动到目标元素
# driver.execute_script("arguments[0].scrollIntoView();", element)

from selenium import webdriver
import time

from selenium.webdriver.common.by import By

driver = webdriver.Edge()
# 打开一个网页
#driver.get("http://www.sahitest.com/demo/framesTest.htm")
driver.get("https://www.douyu.com/directory/all")

driver.maximize_window()
time.sleep(6)
#向下滚动
for i in range(5):
    driver.execute_script('window.scrollBy(0, 10000)')
    time.sleep(2)
driver.quit()
# driver.execute_script('window.scrollTo(0, 200)')
# time.sleep(2)
# driver.execute_script("document.documentElement.scrollTop=300")
# time.sleep(2)
# #向上滚动
# driver.execute_script('window.scrollBy(0, -100)')
# time.sleep(2)
# driver.execute_script('window.scrollTo(0, -200)')
# time.sleep(2)
# driver.execute_script("document.documentElement.scrollTop=-300")
# time.sleep(2)